////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2008 Michiel Helvensteijn                                    //
//                                                                            //
// This file is part of the Mist compiler.                                    //
//                                                                            //
// The Mist compiler is free software: you can redistribute it and/or modify  //
// it under the terms of the GNU General Public License as published by       //
// the Free Software Foundation, either version 3 of the License, or          //
// (at your option) any later version.                                        //
//                                                                            //
// The Mist compiler is distributed in the hope that it will be useful,       //
// but WITHOUT ANY WARRANTY; without even the implied warranty of             //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              //
// GNU General Public License for more details.                               //
//                                                                            //
// You should have received a copy of the GNU General Public License          //
// along with the Mist compiler.  If not, see <http://www.gnu.org/licenses/>. //
////////////////////////////////////////////////////////////////////////////////

#include "universalnavigator.hpp"

/******************************************************************************
 * Includes                                                                   *
 ******************************************************************************/

#include <boost/foreach.hpp>
#define foreach BOOST_FOREACH

#include "ast/nodetypes.hpp"
#include "messages.hpp"
#include "assert.hpp"

/******************************************************************************
 * Function Implementations                                                   *
 ******************************************************************************/

void UniversalNavigator::visit(shared_ptr<ArrayType> node) {
	assert(node);
	
	node->content_type()->accept(shared_from_this());
	node->size()->accept(shared_from_this());
}

void UniversalNavigator::visit(shared_ptr<FunctionType> node) {
	assert(node);
	
	node->return_type()->accept(shared_from_this());
	foreach (ParameterType paramType, node->parameter_types())
		paramType.type->accept(shared_from_this());
}

void UniversalNavigator::visit(shared_ptr<VariableDeclaration> node) {
	assert(node);
	
	node->type()->accept(shared_from_this());
	foreach (VarDec var, node->variables())
		var.name->accept(shared_from_this());
	ExpressionNavigator::visit(node);
}

void UniversalNavigator::visit(shared_ptr<FunctionDeclaration> node) {
	assert(node);
	
	node->type()->accept(shared_from_this());
	node->name()->accept(shared_from_this());
	foreach(shared_ptr<Identifier> paramName, node->parameter_names())
		paramName->accept(shared_from_this());
		
	StatementNavigator::visit(node);
}

void UniversalNavigator::visit(shared_ptr<RangeType> node) {
	assert(node);
	
	node->type()->accept(shared_from_this());
}

void UniversalNavigator::visit(shared_ptr<CompoundStatement> node) {
	assert(node);
	
	node->name()->accept(shared_from_this());
	
	StatementNavigator::visit(node);
}
